<%@ page contentType="text/html;charset=EUC-KR" %>
<%@ page import="java.io.File"%>
<%@ page import ="java.io.*"%>

<%
	String fileName=request.getParameter("file_name");
	
	String savePath="upload";
	ServletContext context = getServletContext();
	String sDownloadPath = context.getRealPath(savePath);
	String sFilePath = sDownloadPath + "\\"+ fileName;
	
	byte b[] =new byte[4096];
	File ofile = new File(sFilePath);
	
	FileInputStream in = new FileInputStream(sFilePath);
	
	String sMimeType = getServletContext().getMimeType(sFilePath);
	System.out.println("sMimeType >>> "+sMimeType);
	
	if(sMimeType == null)	sMimeType = "application/octet-stream";
	response.setContentType(sMimeType);
	
	String sEncoding = new String (fileName.getBytes("euc-kr"),"8859_1");
	response.setHeader("content-Disposition","attachment; filename="+sEncoding);
	
	ServletOutputStream out2 = response.getOutputStream();
	int numRead;
	
	while((numRead = in.read(b,0,b.length))!=-1){
	out2.write(b,0,numRead);}
	out2.flush();
	out2.close();
	in.close();
	
	%>